<?php 
    session_start();
    if($_SESSION['uid']==""||$_SESSION['level']!="2"){
		exit();
	}
    include('tool/submitValidate.php');
    include('tool/pdo.php');
    include('class/public-data.class.php');
    include('bll/PublicDataBLL.php');
    include('class/student-information-register.class.php');
    include('bll/StudentInformationRegisterBLL.php');

    $action = isset($_POST['action']) ? $_POST['action'] : 0;
    $data = isset($_POST['data']) ? $_POST['data'] : null;

    $result=null;
    switch((int)$action){
        //添加学生
        case 1:
            $studentList=json_decode($data);
            if($studentList!=null){
                $studentInformationRegisterBLL=new StudentInformationRegisterBLL();
                $result=$studentInformationRegisterBLL->addStudentInformation($_SESSION['uid'],$studentList);
            }
            break;
        //更新学生信息
        case 2:
            $studentList=json_decode($data);
            if($studentList!=null){
                $studentInformationRegisterBLL=new StudentInformationRegisterBLL();
                $result=$studentInformationRegisterBLL->updateStudentInfomation($_SESSION['uid'],$studentList);
            }
            break;
        //移除学生    
        case 3:
            $studentList=json_decode($data);
            if($studentList!=null){
                $studentInformationRegisterBLL=new StudentInformationRegisterBLL();
                $result=$studentInformationRegisterBLL->removeStudentInformation($_SESSION['uid'],$studentList);
            }
            break;
        default:break;
    }

    echo json_encode($result,JSON_UNESCAPED_UNICODE);
?>